import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [

  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login')
  },

  {
    path: '/',
    // name: 'layout',
    component: () => import('@/views/layout'),
    children: [
      {
        path: '/',
        name: 'home',
        component: () => import('@/views/home')
      },
      {
        path: '/my',
        name: 'my',
        component: () => import('@/views/my')
      }, {
        path: '/qa',
        name: 'qa',
        component: () => import('@/views/qa')
      }, {
        path: '/video',
        name: 'video',
        component: () => import('@/views/video')
      }
    ]

  },
  {

    name: 'search',
    path: '/search',
    component: () => import('@/views/search')
  },
  {
    name: 'article',
    path: '/article/:articleID',
    component: () => import('@/views/ArticleDetail'),
    // 开启props传参，把路由参数映射到组件的props数据中
    props: true
  },
  {
    name: 'userprofile',
    path: '/user/profile',
    component: () => import('@/views/user-profile')

  }

]

const router = new VueRouter({
  routes
})

export default router
